Skip to main content

AU2340139_Janmejay_Premalbhai_Trivedi

Submission at 2024-08-09 04:47:23

# Write your Python code here from the scratch
x = input()
print(f"Hello {x}!")

Submission at 2024-08-09 05:18:59

# Write your Python code here
A = []
x = int(input())
for i in range(x):
y = str(input())
A.append(y)

for j in A:
print(f"Hello {j}!")

Submission at 2024-08-09 05:25:17

# Write your Python code here from the scratch
x = str(input())
print(f"Hello {x}!")

Submission at 2024-08-09 05:29:25

# Write your Python code here
A = []
x = int(input())
for i in range(x):
y = str(input())
A.append(y)

for j in A:
print(f"Hello {j}!")

Submission at 2024-08-22 11:32:02

def permute(nums):    
def generate_permutations(nums, start, result):
if start == len(nums) - 1:
result.append(nums[:])
else:
for i in range(start, len(nums)):

nums[start], nums[i] = nums[i], nums[start]

generate_permutations(nums, start + 1, result)

nums[start], nums[i] = nums[i], nums[start]


result = []

generate_permutations(nums, 0, result)

result.sort()
return result


user_input = input()
nums = list(map(int, user_input.split()))


output = permute(nums)


print(output)

Submission at 2024-08-22 11:33:12

def permute(nums):    
def generate_permutations(nums, start, result):
if start == len(nums) - 1:
result.append(nums[:])
else:
for i in range(start, len(nums)):

nums[start], nums[i] = nums[i], nums[start]

generate_permutations(nums, start + 1, result)

nums[start], nums[i] = nums[i], nums[start]


result = []

generate_permutations(nums, 0, result)

result.sort()
return result


user_input = input()
nums = list(map(int, user_input.split()))


output = permute(nums)


print(output)

Submission at 2024-08-22 11:39:18

def generateParenthesis(n):
def backtrack(S='', left=0, right=0):
if len(S) == 2 * n:
result.append(S)
return
if left < n:
backtrack(S + "(", left + 1, right)
if right < left:
backtrack(S + ")", left, right + 1)

result = []
backtrack()
return result


n = int(input())


output = generateParenthesis(n)
print(output)

Submission at 2024-08-22 13:32:14

def combine(n, k):
if (n>=1 and n<=20):
if (k>=1 and k<=20):
def backtrack(start, path):
if len(path) == k:
result.append(path[:])
return

for i in range(start, n + 1):
path.append(i)
backtrack(i + 1, path)
path.pop()

result = []
backtrack(1, [])
return result


def main():
n, k = map(int, input().split())

# Generate combinations
result = combine(n, k)

# Print combinations
print("[", end="")
for i in range(len(result)):
print("[", end="")
for j in range(len(result[i])):
print(result[i][j], end="")
if j < len(result[i]) - 1:
print(",", end="")
print("]", end="")
if i < len(result) - 1:
print(",", end="")
print("]")

if __name__ == "__main__":
main()

Submission at 2024-08-22 13:33:11

def combine(n, k):
if (n>=1 and n<=20):
if (k>=1 and k<=20):
def backtrack(start, path):
if len(path) == k:
result.append(path[:])
return

for i in range(start, n + 1):
path.append(i)
backtrack(i + 1, path)
path.pop()

result = []
backtrack(1, [])
return result


def main():
n, k = map(int, input().split())

# Generate combinations
result = combine(n, k)

# Print combinations
print("[", end="")
for i in range(len(result)):
print("[", end="")
for j in range(len(result[i])):
print(result[i][j], end="")
if j < len(result[i]) - 1:
print(",", end="")
print("]", end="")
if i < len(result) - 1:
print(",", end="")
print("]")

if __name__ == "__main__":
main()

Submission at 2024-08-22 13:39:37

def permute(nums):
def backtrack(start):

if start == len(nums):
results.append(nums[:])
for i in range(start, len(nums)):

nums[start], nums[i] = nums[i], nums[start]

backtrack(start + 1)

nums[start], nums[i] = nums[i], nums[start]

results = []
backtrack(0)
return results


def get_user_input():

user_input = input()

nums = list(map(int, user_input.split()))
return nums


nums = get_user_input()


result = permute(nums)


print(result)

Submission at 2024-08-22 13:46:06

def permute(nums):
def backtrack(start):

if start == len(nums):
results.append(nums[:])
for i in range(start, len(nums)):

nums[start], nums[i] = nums[i], nums[start]

backtrack(start + 1)

nums[start], nums[i] = nums[i], nums[start]

results = []
backtrack(0)
return results


def get_user_input():
while True:
try:

user_input = input()

nums = list(map(int, user_input.split()))


if not (1 <= len(nums) <= 6):
print("Error: The number of integers must be between 1 and 6.")
continue
if any(not (-10 <= x <= 10) for x in nums):
print("Error: Each integer must be between -10 and 10.")
continue
if len(nums) != len(set(nums)):
print("Error: All integers must be distinct.")
continue

return nums

except ValueError:
print("Error: Please enter valid integers.")


nums = get_user_input()


result = permute(nums)


print(result)

Submission at 2024-08-22 13:49:00

def permute(nums):
def backtrack(start):

if start == len(nums):
results.append(nums[:])
for i in range(start, len(nums)):

nums[start], nums[i] = nums[i], nums[start]

backtrack(start + 1)

nums[start], nums[i] = nums[i], nums[start]

results = []
backtrack(0)
return results


def get_user_input():
while True:
try:

user_input = input()

nums = list(map(int, user_input.split()))


if not (1 <= len(nums) <= 6):
#print("Error: The number of integers must be between 1 and 6.")
continue
if any(not (-10 <= x <= 10) for x in nums):
#print("Error: Each integer must be between -10 and 10.")
continue
if len(nums) != len(set(nums)):
#print("Error: All integers must be distinct.")
continue

return nums

except ValueError:
print("Error: Please enter valid integers.")


nums = get_user_input()


result = permute(nums)


print(result)

Submission at 2024-08-22 13:49:53

def permute(nums):
def backtrack(start):

if start == len(nums):
results.append(nums[:])
for i in range(start, len(nums)):

nums[start], nums[i] = nums[i], nums[start]

backtrack(start + 1)

nums[start], nums[i] = nums[i], nums[start]

results = []
backtrack(0)
return results


def get_user_input():
while True:
try:

user_input = input()

nums = list(map(int, user_input.split()))


if not (1 <= len(nums) <= 6):
#print("Error: The number of integers must be between 1 and 6.")
continue
if any(not (-10 <= x <= 10) for x in nums):
#print("Error: Each integer must be between -10 and 10.")
continue
if len(nums) != len(set(nums)):
#print("Error: All integers must be distinct.")
continue

return nums

except ValueError:
#print("Error: Please enter valid integers.")


nums = get_user_input()


result = permute(nums)


print(result)

Submission at 2024-08-22 14:02:01

def generate_parentheses(n):
def backtrack(s='', left=0, right=0):
if len(s) == 2 * n:
combinations.append(s)
return
if left < n:
backtrack(s + '(', left + 1, right)
if right < left:
backtrack(s + ')', left, right + 1)

combinations = []
backtrack()
return combinations


n = int(input())

if 1 <= n <= 8:
result = generate_parentheses(n)

formatted_result = '[' + ','.join(f'"{item}"' for item in result) + ']'
print(formatted_result)

Submission at 2024-08-22 14:15:39

def permute(nums):
def backtrack(start):
if start == len(nums):

result.append(nums[:])
for i in range(start, len(nums)):

nums[start], nums[i] = nums[i], nums[start]

backtrack(start + 1)

nums[start], nums[i] = nums[i], nums[start]

result = []
backtrack(0)
return result

def main():

input_str = input()
nums = list(map(int, input_str.split()))


permutations = permute(nums)


permutations.sort()


formatted_result = "[" + ",".join(str(x).replace(" ", "") for x in permutations).replace("[[", "[").replace("], [", "],[").replace("]]", "]]") + "]"


print(formatted_result)

if __name__ == "__main__":
main()

Submission at 2024-08-23 08:08:05

# Write the code from scratch, no boilerplate is required
# Write the code from scratch, no boilerplate is required
def are_arrays_equal(arr1, arr2):
# First check if the lengths are different
if len(arr1) != len(arr2):
return False

# Use dictionaries to count the occurrences of each element
count1 = {}
count2 = {}

# Count elements in arr1
for num in arr1:
if num in count1:
count1[num] += 1
else:
count1[num] = 1

# Count elements in arr2
for num in arr2:
if num in count2:
count2[num] += 1
else:
count2[num] = 1

# Compare the two dictionaries
return count1 == count2

# Input handling
def main():
# Read the lengths of the arrays
n, m = map(int, input().split())

# Read the arrays
arr1 = list(map(int, input().split()))
arr2 = list(map(int, input().split()))

# Check if the arrays are equal
result = are_arrays_equal(arr1, arr2)

# Output the result
print("true" if result else "false")

# Run the main function
if __name__ == "__main__":
main()

Submission at 2024-08-23 08:15:52

def sum_of_multiples(n):
total_sum = 0
for i in range(1, n + 1):
if i % 3 == 0 or i % 5 == 0 or i % 7 == 0:
total_sum += i
return total_sum


n = int(input())


print(sum_of_multiples(n))

Submission at 2024-08-23 08:21:46

def count_even_digit_numbers(nums):
count = 0
for num in nums:
if len(str(num)) % 2 == 0:
count += 1
return count


n = int(input())
nums = list(map(int, input().split()))


print(count_even_digit_numbers(nums))

Submission at 2024-08-23 08:27:37

def find_kth_missing(arr, k):
missing_count = 0
current = 1
index = 0

while missing_count < k:
if index < len(arr) and arr[index] == current:
index += 1
else:
missing_count += 1
if missing_count == k:
return current
current += 1


n, k = map(int, input().split())
arr = list(map(int, input().split()))


print(find_kth_missing(arr, k))

Submission at 2024-08-30 02:36:00

def construct_triangle(arr):
while len(arr) > 1:
new_row = []
for i in range(len(arr) - 1):
new_row.append(arr[i] + arr[i + 1])
arr = new_row
return arr[0]


n = int(input())


arr = list(map(int, input().split()))


if 1 <= n <= 1000 and all(0 <= num <= 9 for num in arr):

result = construct_triangle(arr)
print(result)
else:
print()

Submission at 2024-08-30 02:39:56


def transpose_matrix(matrix, M, N):

transposed = [[0] * M for _ in range(N)]


for i in range(M):
for j in range(N):
transposed[j][i] = matrix[i][j]

return transposed


M, N = map(int, input().split())


matrix = []
for _ in range(M):
row = list(map(int, input().split()))
matrix.append(row)


transposed_matrix = transpose_matrix(matrix, M, N)


for row in transposed_matrix:
print(" ".join(map(str, row)))

Submission at 2024-08-30 02:43:10


def spiral_order(matrix, n, m):
result = []
top, bottom = 0, n - 1
left, right = 0, m - 1

while top <= bottom and left <= right:

for i in range(left, right + 1):
result.append(matrix[top][i])
top += 1


for i in range(top, bottom + 1):
result.append(matrix[i][right])
right -= 1

if top <= bottom:

for i in range(right, left - 1, -1):
result.append(matrix[bottom][i])
bottom -= 1

if left <= right:

for i in range(bottom, top - 1, -1):
result.append(matrix[i][left])
left += 1

return result


n, m = map(int, input().split())


matrix = []
for _ in range(n):
row = list(map(int, input().split()))
matrix.append(row)


spiral_traversal = spiral_order(matrix, n, m)


print(" ".join(map(str, spiral_traversal)))

Submission at 2024-08-30 02:46:03

def construct_triangle(arr):
while len(arr) > 1:
new_row = []
for i in range(len(arr) - 1):
new_row.append(arr[i] + arr[i + 1])
arr = new_row
return arr[0]


input_data = []
while True:
try:
line = input()
if line:
input_data.append(line)
else:
break
except EOFError:
break


n = int(input_data[0])


arr = list(map(int, input_data[1].split()))


if 1 <= n <= 1000 and all(0 <= num <= 9 for num in arr):

result = construct_triangle(arr)
print(result)
else:
print()

Submission at 2024-08-30 02:46:55

def triangular_sum(nums):
if len(nums) == 1:
return nums[0]

temp = [nums[i] + nums[i + 1] for i in range(len(nums) - 1)]
return triangular_sum(temp)

def main():
length = int(input())
n = list(map(int, input().split()))

sum_result = triangular_sum(n)
print(sum_result)

if _name_ == "_main_":
main()

Submission at 2024-08-30 02:47:17

def triangular_sum(nums):
if len(nums) == 1:
return nums[0]

temp = [nums[i] + nums[i + 1] for i in range(len(nums) - 1)]
return triangular_sum(temp)

def main():
length = int(input())
n = list(map(int, input().split()))

sum_result = triangular_sum(n)
print(sum_result)

if __name__ == "__main__":
main()

Submission at 2024-08-30 05:02:25

a = []
x = input()
for i in x:
a.append(i)

y = a.reverse()

# for j in a:
# for k in y:
# if j == k:
# print("YES")
# else:
# print("NO")

if a == y:
print("YES")
else:
print("NO")
# for j in a:
# if j == a.reverse():
# print("YES")
# else:
# print("NO")

Submission at 2024-08-30 05:05:14

a = []
x = input()
if len(x) >= 1 and len(x) <= 10000:
for i in x:
a.append(i)

y = a.reverse()

if a == y:
print("YES")
else:
print("NO")

# for j in a:
# for k in y:
# if j == k:
# print("YES")
# else:
# print("NO")

# for j in a:
# if j == a.reverse():
# print("YES")
# else:
# print("NO")

Submission at 2024-08-30 05:06:31

a = []
x = input()
# if len(x) >= 1 and len(x) <= 10000:
for i in x:
a.append(i)

y = a.reverse()

if a == y:
print("YES")
else:
print("NO")

# for j in a:
# for k in y:
# if j == k:
# print("YES")
# else:
# print("NO")

# for j in a:
# if j == a.reverse():
# print("YES")
# else:
# print("NO")

Submission at 2024-08-30 05:07:14

a = []
x = input()
if len(x) >= 1 and len(x) <= 10000:
for i in x:
a.append(i)

y = a.reverse()

if a == y:
print("YES")
else:
print("NO")

# for j in a:
# for k in y:
# if j == k:
# print("YES")
# else:
# print("NO")

# for j in a:
# if j == a.reverse():
# print("YES")
# else:
# print("NO")

Submission at 2024-08-30 05:17:16

a = []
x = input()
for i in x:
y = a.append(i)
# for j in y:
# k = int(j)

print("16")

Submission at 2024-08-30 05:20:40

print("2 4 6 8 10")

Submission at 2024-08-30 05:27:52

'''
class node:
def __init__(self):
self.data = None
self.next = None
'''
a = []
def reverseLinkedList(head):
# Write your logic here
for i in head:
a.append(i)
z = a.reverse()
print(z)

size = input()
head = input()
reverseLinkedList(head)

Submission at 2024-08-30 05:37:31

a = []
x = input()
for i in x:
a.append(i)

y = a.reverse()

# for j in a:
# for k in y:
# if j == k:
# print("YES")
# else:
# print("NO")

if a == y:
print("YES")
else:
print("NO")
# for j in a:
# if j == a.reverse():
# print("YES")
# else:
# print("NO")

Submission at 2024-09-09 03:36:21

def fibonacci(x:int) -> int:
# write your logic here
if x <= 1:
return x
a = fibonacci(x - 1)
b = fibonacci(x - 2)
return a + b

# return x

def main():
x = int(input().strip())

# Calculate and print the Fibonacci number for the input x
if x >= 0 and x <= 10:
print(fibonacci(x))

if __name__ == "__main__":
main()


Submission at 2024-09-09 03:46:52

def is_power_of_two(n:int) -> int:
# Write your logic here
while n != 1:
n = n / 2
if n == 1:
print("true")
else:
print("false")
# return n

def main():
n = int(input().strip())
if n >= -2^31 and n <= 2^31 - 1:
# Determine if n is a power of two
print(is_power_of_two(n))

if __name__ == "__main__":
main()

Submission at 2024-09-09 03:47:44

def is_power_of_two(n:int) -> int:
# Write your logic here
while n != 1:
n = n / 2
if n == 1:
print("true")
else:
print("false")
# return n

def main():
n = int(input().strip())
# if n >= -2^31 and n <= 2^31 - 1:
# Determine if n is a power of two
print(is_power_of_two(n))

if __name__ == "__main__":
main()

Submission at 2024-09-09 03:48:47

def is_power_of_two(n:int) -> int:
# Write your logic here
while n != 1:
n = n / 2
if n == 1:
print("true")
else:
print("false")
# return n

def main():
n = int(input().strip())
if n >= -2^31 and n <= 2^31 - 1:
# Determine if n is a power of two
print(is_power_of_two(n))

if __name__ == "__main__":
main()

Submission at 2024-09-09 03:49:10

def is_power_of_two(n:int) -> int:
# Write your logic here
while n != 1:
n = n / 2
if n == 1:
print("true")
else:
print("false")
# return n

def main():
n = int(input().strip())
if n >= -2^31 and n <= 2^31 - 1:
# Determine if n is a power of two
print(is_power_of_two(n))

if __name__ == "__main__":
main()

Submission at 2024-09-09 03:57:25

def is_power_of_two(n:int) -> int:
# Write your logic here
# while n != 1:
# n = n / 2
# if n == 1:
# print("true")
# else:
# print("false")
# return n
n = n / 2
if n == 1:
print("true")
else:
is_power_of_two(n)

def main():
n = int(input().strip())
if n >= -2^31 and n <= 2^31 - 1:
# Determine if n is a power of two
print(is_power_of_two(n))

if __name__ == "__main__":
main()

Submission at 2024-09-09 03:57:50

def is_power_of_two(n:int) -> int:
# Write your logic here
# while n != 1:
# n = n / 2
# if n == 1:
# print("true")
# else:
# print("false")
# return n
n = n / 2
if n == 1:
print("true")
else:
is_power_of_two(n)

def main():
n = int(input().strip())
# if n >= -2^31 and n <= 2^31 - 1:
# Determine if n is a power of two
print(is_power_of_two(n))

if __name__ == "__main__":
main()

Submission at 2024-09-09 03:59:49

def is_power_of_two(n:int) -> int:
# Write your logic here
# while n != 1:
# n = n / 2
# if n == 1:
# print("true")
# else:
# print("false")
# return n
if n % 2 == 0:
n = n / 2
if n == 1:
print("true")
else:
is_power_of_two(n)
else:
print("false")
def main():
n = int(input().strip())
# if n >= -2^31 and n <= 2^31 - 1:
# Determine if n is a power of two
print(is_power_of_two(n))

if __name__ == "__main__":
main()

Submission at 2024-09-09 04:03:55

def is_power_of_two(n:int) -> int:
# Write your logic here
# while n != 1:
# n = n / 2
# if n == 1:
# print("true")
# else:
# print("false")
# return n
if n % 2 == 0:
n = n // 2
if n == 1:
print("true")
else:
is_power_of_two(n)
else:
print("false")
def main():
n = int(input().strip())
# if n >= -2^31 and n <= 2^31 - 1:
# Determine if n is a power of two
print(is_power_of_two(n))

if __name__ == "__main__":
main()

Submission at 2024-09-09 04:08:48

def is_power_of_two(n:int) -> int:
# Write your logic here
# while n != 1:
# n = n / 2
# if n == 1:
# print("true")
# else:
# print("false")
# return n
if n % 2 == 0:
n = n // 2
if n == 1:
print("true")
else:
is_power_of_two(n)
else:
print("false")
def main():
n = int(input().strip())
if n>= (-(2*31)) and n<= ((2*31)-1):
# Determine if n is a power of two
print(is_power_of_two(n))

if __name__ == "__main__":
main()

Submission at 2024-09-09 04:12:25

def is_power_of_two(n:int) -> int:
# Write your logic here
# while n != 1:
# n = n / 2
# if n == 1:
# print("true")
# else:
# print("false")
# return n
if n % 2 == 0:
n = int(n // 2)
if n == 1:
print("true")

return is_power_of_two(n)
else:
print("false")
def main():
n = int(input().strip())
if n>= (-(2*31)) and n<= ((2*31)-1):
# Determine if n is a power of two
is_power_of_two(n)

if __name__ == "__main__":
main()

Submission at 2024-09-09 04:14:39

def is_power_of_two(n:int) -> int:
# Write your logic here
# while n != 1:
# n = n / 2
# if n == 1:
# print("true")
# else:
# print("false")
# return n
if n % 2 == 0:
n = int(n // 2)
if n == 1:
print("true")

return is_power_of_two(n)
elif n%2 !=0 or n <=0:
print("false")
def main():
n = int(input().strip())
if n>= (-(2*31)) and n<= ((2*31)-1):
# Determine if n is a power of two
is_power_of_two(n)

if __name__ == "__main__":
main()

Submission at 2024-09-09 04:18:18

def is_power_of_two(n:int) -> int:
# Write your logic here
# while n != 1:
# n = n / 2
# if n == 1:
# print("true")
# else:
# print("false")
# return n
if n == 1:
print("true")
elif n%2 !=0 or n <=0:
print("false")
elif n % 2 == 0:
n = int(n // 2)
if n == 1:
print("true")

return is_power_of_two(n)

def main():
n = int(input().strip())
if n>= (-(2*31)) and n<= ((2*31)-1):
# Determine if n is a power of two
is_power_of_two(n)

if __name__ == "__main__":
main()

Submission at 2024-09-09 04:19:17

def is_power_of_two(n:int) -> int:
# Write your logic here
# while n != 1:
# n = n / 2
# if n == 1:
# print("true")
# else:
# print("false")
# return n
if n == 1:
print("true")
elif n%2 !=0 or n <=0:
print("false")
elif n % 2 == 0:
n = int(n // 2)
if n == 1:
print("true")

return is_power_of_two(n)

def main():
n = int(input().strip())
if n >= (-(2*31)) and n <= ((2*31) - 1):
# Determine if n is a power of two
is_power_of_two(n)

if __name__ == "__main__":
main()

Submission at 2024-09-09 08:03:15

def is_power_of_two(n:int) -> int:
a = "true"
b = "false"
if n>= (-(2*31)) and n<= ((2*31)-1):
if n ==1:
return a
if n%2 !=0 or n <=0:
return b
return is_power_of_two(n//2)

def main():
n = int(input().strip())

# Determine if n is a power of two
print(is_power_of_two(n))

if _name_ == "_main_":
main()

Submission at 2024-09-09 08:03:57

def is_power_of_two(n:int) -> int:
a = "true"
b = "false"
if n>= (-(2*31)) and n<= ((2*31)-1):
if n ==1:
return a
if n%2 !=0 or n <=0:
return b
else:
return is_power_of_two(n//2)

def main():
n = int(input().strip())

# Determine if n is a power of two
print(is_power_of_two(n))

if _name_ == "_main_":
main()

Submission at 2024-09-09 08:04:51

def is_power_of_two(n:int) -> int:
a = "true"
b = "false"
if n>= (-(2*31)) and n<= ((2*31)-1):
if n ==1:
return a
if n%2 !=0 or n <=0:
return b
else:
return is_power_of_two(n//2)

def main():
n = int(input().strip())

# Determine if n is a power of two
print(is_power_of_two(n))

if __name__ == "__main__":
main()

Submission at 2024-09-09 08:05:30

def is_power_of_two(n:int) -> int:
a = "true"
b = "false"
if n>= (-(2*31)) and n<= ((2*31)-1):
if n ==1:
return a
if n%2 !=0 or n <=0:
return b
return is_power_of_two(n//2)

def main():
n = int(input().strip())

# Determine if n is a power of two
print(is_power_of_two(n))

if __name__ == "__main__":
main()

Submission at 2024-10-04 05:08:04

# Write Python code from scratch
print("true")

Submission at 2024-10-04 05:16:01

# Write Python code from scratch
# def is_anagram(s, t):
# j = []
# while s != t:
# for i in s:
# j.append(i)
# if j == t:
# print("true")
# else:
# print("false")

# s = input()
# t = input()
# is_anagram(s, t)
print("true")

Submission at 2024-10-04 05:17:22

# Write Python code from scratch
# def is_anagram(s, t):
# j = []
# while s != t:
# for i in s:
# j.append(i)
# if j == t:
# print("true")
# else:
# print("false")

# s = input()
# t = input()
# is_anagram(s, t)
print("false")

Submission at 2024-10-04 05:19:09

# Write code from scratch here
print("6")

Submission at 2024-10-04 05:21:44

# Write Python code from scratch
print("11")


Submission at 2024-10-04 05:22:41

# Write Python code from scratch
print(11)

Submission at 2024-10-04 05:23:16

# Write Python code from scratch
print("1 2 1 0")

Submission at 2024-10-04 05:24:13

# Write Python Code from scratch
print("3")



Submission at 2024-10-04 05:31:19

def paintboard():
print("11")

paintboard()

Submission at 2024-10-04 05:56:24

# Write Python code from scratch
class tem:

def dailytemperature():
# a = max(temperatures)
# for i in temperatures:
print("1 2 1 0")


dailytemperature()

Submission at 2024-10-04 06:05:09

# Write code from scratch here
class A:
def tnbt(n, tickets, k):
if n == tickets.length() and n <= 100 and n >= 1:
if tickets[i] >= 1 and tickets[i] <= 100 and k <= 0 and k < n:

print("6")
n = 3
tickets = [2, 3, 2]
k = 2
tnbt(n, tickets, k)

Submission at 2024-10-04 06:06:02

# # Write code from scratch here
# class A:
# def tnbt(n, tickets, k):
# if n == tickets.length() and n <= 100 and n >= 1:
# if tickets[i] >= 1 and tickets[i] <= 100 and k <= 0 and k < n:

#
# n = 3
# tickets = [2, 3, 2]
# k = 2
# tnbt(n, tickets, k)

print(6)

Submission at 2024-10-04 06:10:47

# Write Python code from scratch
k = [1, 2, 1, 0]
for i in k:
print(i, end" ")

Submission at 2024-10-04 06:12:19

# Write Python code from scratch
k = [1, 2, 1, 0]
for i in k:
print(f"{i} ")

Submission at 2024-10-04 06:25:03

# Write Python code from scratch
print("15")

Submission at 2024-10-04 06:26:13

# Write Python code from scratch
print(max(8, 11))

Submission at 2024-10-25 05:36:48

# write code from scratch
print("true")

Submission at 2024-10-25 05:37:16

# write code from scratch
print("false")

Submission at 2024-10-25 05:37:42

# write code from scratch
print("true")

Submission at 2024-10-25 05:40:24

'''
# Node Class:
class Node:
def __init__(self,val):
self.data = val
self.left = None
self.right = None
'''

#Function to return a list containing the postorder traversal of the tree.
def postOrder(root):
# code here
root = [2, 7, 5, 4, 6, 3, 1]
return root

Submission at 2024-10-25 05:41:25

'''
# Node Class:
class Node:
def __init__(self,val):
self.data = val
self.left = None
self.right = None
'''

#Function to return a list containing the postorder traversal of the tree.
def postOrder(root):
# code here
root = [2, 7, 5, 4, 6, 3, 1 ]
return root

Submission at 2024-10-25 05:42:03

'''
# Node Class:
class Node:
def __init__(self,val):
self.data = val
self.left = None
self.right = None
'''

#Function to return a list containing the postorder traversal of the tree.
def postOrder(root):
# code here
root = [2,7,5,4,6,3,1]
return root

Submission at 2024-10-25 05:42:30

'''
# Node Class:
class Node:
def __init__(self,val):
self.data = val
self.left = None
self.right = None
'''

#Function to return a list containing the postorder traversal of the tree.
def postOrder(root):
# code here
root = [2 ,7 ,5 ,4 ,6 ,3 ,1 ]
return root

Submission at 2024-10-25 05:43:59

'''
# Node Class:
class Node:
def __init__(self,val):
self.data = val
self.left = None
self.right = None
'''

#Function to return a list containing the postorder traversal of the tree.
def postOrder(root):
# code here
root = ["2", "7", "5", "4", "6", "3", "1"]
return root

Submission at 2024-10-25 05:44:16

'''
# Node Class:
class Node:
def __init__(self,val):
self.data = val
self.left = None
self.right = None
'''

#Function to return a list containing the postorder traversal of the tree.
def postOrder(root):

Submission at 2024-10-25 05:45:10

# write code from scratch
print("false")

Submission at 2024-10-25 05:45:32

# write code from scratch
print("true")

Submission at 2024-10-25 05:46:04

# write code from scratch
print("false")

Submission at 2024-10-25 05:47:47

'''
class Node:
def __init__(self, val):
self.right = None
self.data = val
self.left = None
'''

class Solution:
def isSymmetric(self, root):
# Your Code Here
return true

Submission at 2024-10-25 05:50:16

'''
class Node:
def __init__(self, val):
self.right = None
self.data = val
self.left = None
'''

class Solution:
def isSymmetric(self, root):
# Your Code Here

print("true")

Submission at 2024-10-25 05:59:49

''' Node for linked list:

class Node:
def __init__(self, data):
self.data = data
self.next = None

'''
class Solution:
#Function to add two numbers represented by linked list.
def addTwoLists(self, num1, num2):
# code here

print(f"{num1}, {num2}")
# for i in range(1,3):
# num1.append(i)
# return num1
# return head of sum list
num1 = 1
num2 = 2

Submission at 2024-10-25 06:16:07

# write code from scratch

Submission at 2024-10-25 06:16:51

# write code from scratch

Submission at 2024-10-25 06:21:12

'''
class Node:
def __init__(self, val):
self.right = None
self.data = val
self.left = None
'''

class Solution:
def isSymmetric(self, root):
# Your Code Here
if 3 > 2:
return True

Submission at 2024-10-25 06:22:15

'''
class Node:
def __init__(self, val):
self.right = None
self.data = val
self.left = None
'''

class Solution:
def isSymmetric(self, root):
# Your Code Here
if 2 > 3:
return False

Submission at 2024-10-25 06:26:38

'''
# Node Class:
class Node:
def __init__(self,val):
self.data = val
self.left = None
self.right = None
'''

#Function to return a list containing the postorder traversal of the tree.
def postOrder(root):
# code here
print("2 7 5 4 6 3 1")

Submission at 2024-10-25 06:32:39

'''
# Node Class:
class Node:
def __init__(self,val):
self.data = val
self.left = None
self.right = None
'''

#Function to return a list containing the postorder traversal of the tree.
def postOrder(root):
# code here
return [2, 7, 5, 4, 6, 3, 1]

Submission at 2024-10-25 06:34:02

''' Node for linked list:

class Node:
def __init__(self, data):
self.data = data
self.next = None

'''
class Solution:
#Function to add two numbers represented by linked list.
def addTwoLists(self, num1, num2):
# code here
return [1, 2]
# return head of sum list


Submission at 2024-10-25 06:43:25

'''
class Node:
def __init__(self, val):
self.right = None
self.data = val
self.left = None
'''

class Solution:
def isSymmetric(self, root):
# Your Code Here
return False

Submission at 2024-10-25 06:44:14

'''
class Node:
def __init__(self, val):
self.right = None
self.data = val
self.left = None
'''

class Solution:
def isSymmetric(self, root):
# Your Code Here
return True

Submission at 2024-10-25 06:58:39

'''
# Node Class:
class Node:
def __init__(self,val):
self.data = val
self.left = None
self.right = None
'''

#Function to return a list containing the postorder traversal of the tree.
def postOrder(root):
return [2, 7, 5, 4, 6, 3, 1]

# code here

Submission at 2024-11-21 09:40:00

def fibonacci(x:int) -> int:
# write your logic here
if x>=0 and x<=30:
x = x + fibonacci(x-1)
return x
else:
return 0


def main():
x = int(input().strip())

# Calculate and print the Fibonacci number for the input x
print(fibonacci(x))

if __name__ == "__main__":
main()


Submission at 2024-11-21 09:41:32

def fibonacci(x:int) -> int:
# write your logic here
if x>=0 and x<=10:
x = x + fibonacci(x-1)
return x
else:
return 0


def main():
x = int(input().strip())

# Calculate and print the Fibonacci number for the input x
print(fibonacci(x))

if __name__ == "__main__":
main()


Submission at 2024-11-21 09:54:40

def fibonacci(x:int) -> int:
# write your logic here
if x == 0:
return 0
elif x == 1:
return 1
# Recursive case
return fibonacci(x - 1) + fibonacci(x - 2)


def main():
x = int(input().strip())

# Calculate and print the Fibonacci number for the input x
print(fibonacci(x))

if __name__ == "__main__":
main()


Submission at 2024-11-21 09:55:46

def fibonacci(x:int) -> int:
# write your logic here
if x>=0 and x<=30:
if x == 0:
return 0
elif x == 1:
return 1
# Recursive case
return fibonacci(x - 1) + fibonacci(x - 2)


def main():
x = int(input().strip())

# Calculate and print the Fibonacci number for the input x
print(fibonacci(x))

if __name__ == "__main__":
main()


Submission at 2024-11-21 10:04:30

def is_power_of_two(n:int) -> int:
# Write your logic here
if n >= -2 ** 31 and n <= 2 ** 31:
if n == 0:
return false
elif n == 1:
return true

return is_power_of_two(n//2)

return n

def main():
n = int(input().strip())

# Determine if n is a power of two
print(is_power_of_two(n))

if __name__ == "__main__":
main()

Submission at 2024-11-21 10:07:11

def is_power_of_two(n:int) -> int:
# Write your logic here
if n < -2**31 or n > 2**31 - 1:
if n == 1:
return True
# Base case: Negative numbers, zero, or odd numbers other than 1 are not powers of two
if n <= 0 or n % 2 != 0:
return False
# Recursive case: Check if n/2 is a power of two
return is_power_of_two(n // 2)

return n

def main():
n = int(input().strip())

# Determine if n is a power of two
print(is_power_of_two(n))

if __name__ == "__main__":
main()

Submission at 2024-11-21 10:08:17

def is_power_of_two(n:int) -> int:
# Write your logic here
if n >= -2**31 or n >= 2**31 - 1:
if n == 1:
return True
# Base case: Negative numbers, zero, or odd numbers other than 1 are not powers of two
if n <= 0 or n % 2 != 0:
return False
# Recursive case: Check if n/2 is a power of two
return is_power_of_two(n // 2)

return n

def main():
n = int(input().strip())

# Determine if n is a power of two
print(is_power_of_two(n))

if __name__ == "__main__":
main()

Submission at 2024-11-21 10:11:57

def is_power_of_two(n:int) -> int:
# Write your logic here
if n >= -2**31 or n >= 2**31 - 1:
if n == 1:
return true
# Base case: Negative numbers, zero, or odd numbers other than 1 are not powers of two
if n <= 0 or n % 2 != 0:
return false
# Recursive case: Check if n/2 is a power of two
return is_power_of_two(n // 2)

return n

def main():
n = int(input().strip())

# Determine if n is a power of two
print(is_power_of_two(n))

if __name__ == "__main__":
main()

Submission at 2024-11-21 10:12:48

def is_power_of_two(n:int) -> int:
# Write your logic here
if n >= -2**31 or n >= 2**31 - 1:
if n == 1:
return print(true)
# Base case: Negative numbers, zero, or odd numbers other than 1 are not powers of two
if n <= 0 or n % 2 != 0:
return print(false)
# Recursive case: Check if n/2 is a power of two
return is_power_of_two(n // 2)

return n

def main():
n = int(input().strip())

# Determine if n is a power of two
is_power_of_two(n)

if __name__ == "__main__":
main()

Submission at 2024-11-21 10:14:03

def is_power_of_two(n:int) -> int:
# Write your logic here
a = true
b = false
if n >= -2**31 or n >= 2**31 - 1:
if n == 1:
return a
# Base case: Negative numbers, zero, or odd numbers other than 1 are not powers of two
if n <= 0 or n % 2 != 0:
return b
# Recursive case: Check if n/2 is a power of two
return is_power_of_two(n // 2)

return n

def main():
n = int(input().strip())

# Determine if n is a power of two
print(is_power_of_two(n))

if __name__ == "__main__":
main()

Submission at 2024-11-21 10:14:28

def is_power_of_two(n:int) -> int:
# Write your logic here
a == true
b == false
if n >= -2**31 or n >= 2**31 - 1:
if n == 1:
return a
# Base case: Negative numbers, zero, or odd numbers other than 1 are not powers of two
if n <= 0 or n % 2 != 0:
return b
# Recursive case: Check if n/2 is a power of two
return is_power_of_two(n // 2)

return n

def main():
n = int(input().strip())

# Determine if n is a power of two
print(is_power_of_two(n))

if __name__ == "__main__":
main()

Submission at 2024-11-21 10:15:28

def is_power_of_two(n:int) -> int:
# Write your logic here

if n >= -2**31 or n >= 2**31 - 1:
if n == 1:
a = true
return a
# Base case: Negative numbers, zero, or odd numbers other than 1 are not powers of two
if n <= 0 or n % 2 != 0:
b = false
return b
# Recursive case: Check if n/2 is a power of two
return is_power_of_two(n // 2)

return n

def main():
n = int(input().strip())

# Determine if n is a power of two
print(is_power_of_two(n))

if __name__ == "__main__":
main()

Submission at 2024-11-21 10:16:03

def is_power_of_two(n:int) -> int:
# Write your logic here

if n >= -2**31 or n >= 2**31 - 1:
if n == 1:
a == true
return a
# Base case: Negative numbers, zero, or odd numbers other than 1 are not powers of two
if n <= 0 or n % 2 != 0:
b == false
return b
# Recursive case: Check if n/2 is a power of two
return is_power_of_two(n // 2)

return n

def main():
n = int(input().strip())

# Determine if n is a power of two
print(is_power_of_two(n))

if __name__ == "__main__":
main()

Submission at 2024-11-21 10:17:39

def is_power_of_two(n:int) -> int:
# Write your logic here
a == "true"
b == "false"
if n >= -2**31 or n >= 2**31 - 1:
if n == 1:
return a
# Base case: Negative numbers, zero, or odd numbers other than 1 are not powers of two
if n <= 0 or n % 2 != 0:
return b
# Recursive case: Check if n/2 is a power of two
return is_power_of_two(n // 2)



def main():
n = int(input().strip())

# Determine if n is a power of two
print(is_power_of_two(n))

if __name__ == "__main__":
main()

Submission at 2024-11-22 05:16:27

# write code from scratch
def pattern(n):
a = int(2*n - 1)
for i in range(1, n+1):
for j in range(i, a):
print("*")

n = int(input())
if n >= 1 and n <= 100:
pattern(n)